package library.and.xps.com.step.view.activity;

import android.content.Intent;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.github.lguipeng.library.animcheckbox.AnimCheckBox;
import com.zhy.autolayout.AutoLinearLayout;

import library.and.xps.com.step.R;
import library.and.xps.com.step.URLConstants;
import library.and.xps.com.step.m.model.RequestParams;
import library.and.xps.com.step.m.netapi.OkHttpClientUtils;
import library.and.xps.com.step.util.TeamHelper;
import library.and.xps.com.step.view.base.BaseActivity;

public class ChallengerChipsChooseActivity extends BaseActivity implements AnimCheckBox.OnCheckedChangeListener {
    AnimCheckBox cb_1, cb_2, cb_3, cb_4;
    TextView tv_right;
    String str = "真心话大冒险";
    AutoLinearLayout al_modify_chip;
    EditText et_modify_content;

    @Override
    protected int getLayout() {
        return R.layout.activity_dialog_challenger_chips_choose;
    }

    @Override
    protected void setData() {

    }

    @Override
    protected void init() {
        cb_1 = r2v(R.id.cb_1);
        cb_2 = r2v(R.id.cb_2);
        cb_3 = r2v(R.id.cb_3);
        cb_4 = r2v(R.id.cb_4);
        et_modify_content = r2v(R.id.et_modify_content);
        et_modify_content.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                str = s.toString();
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });

        al_modify_chip = r2v(R.id.al_modify_chip);
        cb_1.setOnCheckedChangeListener(this);
        cb_2.setOnCheckedChangeListener(this);
        cb_3.setOnCheckedChangeListener(this);
        cb_4.setOnCheckedChangeListener(this);
        tv_right = r2v(R.id.actionbar_tv_right);
        r2v(R.id.actionbar_iv_back).setOnClickListener(this);
        tv_right.setOnClickListener(this);
        tv_right.setText("确定");
        tv_right.setVisibility(View.VISIBLE);

        ((TextView)r2v(R.id.actionbar_tv_title)).setText("挑战筹码");
    }

    @Override
    public void onChange(AnimCheckBox animCheckBox, boolean b) {
        if (animCheckBox.getId() == R.id.cb_1 && b) {
            al_modify_chip.setVisibility(View.GONE);
            str = "真心话大冒险";
            cb_2.setChecked(!b);
            cb_3.setChecked(!b);
            cb_4.setChecked(!b);
        } else if (animCheckBox.getId() == R.id.cb_2 && b) {
            al_modify_chip.setVisibility(View.GONE);
            str = "吃货大礼包";
            cb_1.setChecked(!b);
            cb_3.setChecked(!b);
            cb_4.setChecked(!b);
        } else if (animCheckBox.getId() == R.id.cb_3 && b) {
            al_modify_chip.setVisibility(View.GONE);
            cb_1.setChecked(!b);
            cb_2.setChecked(!b);
            cb_4.setChecked(!b);
            str = "一周爱心早餐";
        } else if (animCheckBox.getId() == R.id.cb_4 && b) {
            al_modify_chip.setVisibility(View.VISIBLE);
            cb_2.setChecked(!b);
            cb_3.setChecked(!b);
            cb_1.setChecked(!b);
            str = "好商量";
        }
    }

    @Override
    public void onClick(View view) {
        super.onClick(view);
        switch (view.getId()) {
            case R.id.actionbar_tv_right:
                Intent i = new Intent();
                i.putExtra("chip", str);
                setResult(1, i);
                finish();
                break;
            case R.id.actionbar_iv_back:
                finish();
                break;
        }
    }
}
